/**
 * @Description TODO
 * @Author zouxiang
 * @Date 2020/3/30/21:46
 */
public class TestRecursion {
    public static void main(String[] args) {

//        long l = System.currentTimeMillis();
//        productForLoop(30);
        StringBuilder sb = new StringBuilder("abcd");
        System.out.println(sb);
        sb = sb.reverse();
        System.out.println(sb);

//        long l1 = System.currentTimeMillis();
//        System.out.printf("计算%d的乘积结果为：%s%n", 10, product(10000000));
//        System.out.printf("计算%d的耗时为：%s%n", 10, System.currentTimeMillis() - l1);

    }

    public static Integer product(Integer integer) {
        if (integer == 1) {
            return 1;
        } else {
            return integer * product(integer - 1);
        }
    }

    public static long productForLoop(long integer) {
        long result = 1;
        while (integer > 1) {
            result *= integer * (integer - 1);
            integer -= 2;
        }
        System.out.println(result);
        return result;
    }
}
